package lifei.lifei.mybatis.jdbcdemo;

import java.sql.*;

public class LinkTabDelect {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //获取连接
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql:///jtsys?serverTimezone=GMT",
                "root",
                "root");
        System.out.println(conn);
        //定义SQL
        String sql = "delete from sys_logs where id = ? ";
        //创建传输器对象
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.setInt(1, 41);
//        执行SQL
        int l = ps.executeUpdate();
        //处理结果集
        if (l > 0){
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }
        //释放资源
        ps.close();
        conn.close();


    }
}
